/*
 * LaTexToolBar object class extends JToolBar
 * used for dynamic toolbar propert
 * THIS IS FOR v1.1
 */
package com.meraklisina.latexeditor;

import javax.swing.JToolBar;

/**
 *
 * @author kursattopcu
 */
public class LatexToolBar extends JToolBar implements Comparable {

    private String name;
    private String configFilePath;
    private boolean visibleOnScreen;
    private int order=-1;
    /**
     * Constructor with no specified order, order will be -1.
     * @param name
     * @param configFilePath
     * @param visibleOnScreen
     */
    public LatexToolBar(String name, String configFilePath,boolean visibleOnScreen) {
        this.name = name;
        this.configFilePath = configFilePath;
        this.visibleOnScreen=visibleOnScreen;
    }
    public LatexToolBar(String name, String configFilePath,boolean visibleOnScreen,int order){
        this(name,configFilePath,visibleOnScreen);
        this.order=order;
    }

    @Override
    public String getName(){
        return this.name;
    }
    public String getConfigFilePath() {
        return configFilePath;
    }

    public void setConfigFilePath(String configFilePath) {
        this.configFilePath = configFilePath;
    }
    public void setVisibleOnScreen(boolean visibleOnScreen){
        this.visibleOnScreen=visibleOnScreen;
    }
    public boolean isAvailable(){
        return this.visibleOnScreen;
    }
    @Override
    public String toString(){
        return this.name;
    }

    public int compareTo(Object arg0) {
        LatexToolBar other=(LatexToolBar)arg0;

        if(this.getOrder()==-1){
            if(other.getOrder()==-1){
                return +1;
            }else{
                return -1;
            }
        }else{
            if(other.getOrder()==-1){
                return +1;
            }else{
                return this.getOrder()>other.getOrder()? +1 : -1 ;
            }
        }
    }

    /**
     * @return the order
     */
    public int getOrder() {
        return order;
    }

    /**
     * @param order the order to set
     */
    public void setOrder(int order) {
        this.order = order;
    }
}
